#pragma once
#include <string>
#include <sys/epoll.h>
#include <netinet/in.h>
#include "epollLoop.hpp"
class EpollLoop;
class Connectfd
{
public:
    enum class State
    {
        ACCEPTING,
        READING,
        WRITEING,
        CLOSE
    };

    Connectfd(int fd_, EpollLoop *eploop, State st = State::READING);
    ~Connectfd();

    void handelEvent(uint32_t events);
    State state();
    int fdVal();

private:
    void handelAccept();
    void handelRead();
    void handelWrite();

    int fd;
    State m_state;
    std::string strRead;
    std::string strWrite;
    EpollLoop *m_epollLoop;
    size_t m_pos = 0;

    static const int BUFFER_LENGTH = 512;
};